import Vue from 'vue'
import App from './App.vue'
import './registerServiceWorker'
import router from './router'
import "./assets/css/global.css"
import "./assets/fonts/iconfont.css"
import axios from "axios"
import TreeTable from "vue-table-with-tree-grid"
//导入loading进度条第三方库
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'
// 配置请求根路径
axios.defaults.baseURL = "http://127.0.0.1:8888/api/private/v1/";
// 配置请求拦截器 请求头中使用 Authorization 字段提供 token 令牌
axios.interceptors.request.use( config =>{
  // console.log(config);
  NProgress.start();
  config.headers.Authorization = window.sessionStorage.getItem("token");
  return config;
})
axios.interceptors.response.use( config =>{
  // console.log(config);
  NProgress.done();
  return config;
})
// 富文本编辑器
import VueQuillEditor from 'vue-quill-editor'
 
// require styles
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'
 
Vue.use(VueQuillEditor);
Vue.prototype.$http = axios;
import { Form, FormItem,Input,Button,Message,MessageBox,Container,
  Header,
  Aside,
  Main,
  Submenu,Menu,MenuItem, 
  RadioGroup,
  RadioButton,
  Card,Row,Col,
  Breadcrumb,
  BreadcrumbItem,
  Table,TableColumn,
  Switch,Tooltip,Pagination,Dialog,Tag,Tree,Select,Option,Cascader,Tabs,
  TabPane,Alert,Steps,Step,CheckboxGroup,Checkbox,Upload,Timeline,
  TimelineItem, } from 'element-ui';
Vue.use(Form);
Vue.use(FormItem);
Vue.use(Input);
Vue.use(Button);
Vue.use(Container);
Vue.use(Header);
Vue.use(Aside);
Vue.use(Main);
Vue.use(Submenu);
Vue.use(Menu);
Vue.use(RadioGroup);
Vue.use(RadioButton);
Vue.use(Card);
Vue.use(Row);
Vue.use(Col);
Vue.use(Breadcrumb);
Vue.use(BreadcrumbItem);
Vue.use(Table);
Vue.use(TableColumn);
Vue.use(Switch);
Vue.use(Tooltip);
Vue.use(Pagination);
Vue.use(Dialog);
Vue.use(Cascader);
Vue.use(MenuItem);
Vue.use(Tag);
Vue.use(Tree);
Vue.use(Select);
Vue.use(Option);
Vue.use(Tabs);
Vue.use(TabPane);
Vue.use(Alert);
Vue.use(Steps);
Vue.use(Step);
Vue.use(CheckboxGroup);
Vue.use(Checkbox);
Vue.use(Upload);
Vue.use(Timeline);
Vue.use(TimelineItem);
Vue.prototype.$message = Message;
Vue.prototype.$confirm = MessageBox.confirm;

Vue.config.productionTip = false;

Vue.component("tree-table",TreeTable);

// 定义全局的时间格式化过滤器
Vue.filter("dateFormat",function (date) {
  const dt = new Date(date);
  const y = dt.getFullYear();
  const m = (dt.getMonth()+1+"").padStart(2,"0");
  const d = (dt.getDate()+"").padStart(2,"0");
  const hh =(dt.getHours()+"").padStart(2,"0");
  const mm =(dt.getMinutes()+"").padStart(2,"0");
  const ss =(dt.getSeconds()+"").padStart(2,"0");
  
  return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
})
new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
